Skip to content

arm_scmi: Fix infinite recursion in transport probe#46

Open
USAVault wants to merge 1 commit into
cixtech:mainfrom
USAVault:main
Open

arm_scmi: Fix infinite recursion in transport probe#46
USAVault wants to merge 1 commit into
cixtech:mainfrom
USAVault:main

Conversation

@USAVault

Copy link
Copy Markdown

Hi CIX-ians, thanks for your hard work! :) I'm trying to run your kernel by applying patches to my OS, and ran into an issue

When DEFINE_SCMI_TRANSPORT_DRIVER() creates an "arm-scmi" child device for each transport (SMC, mailbox, etc.), it also copies the parent's dev->of_node along with the rest of the fwnode. So the child ends up with the same OF node as its parent
When the child device is added, platform_match() calls of_driver_match_device(), sees the node matches the transport driver's of_match_table, and probes away spawning another "arm-scmi" -> another probe -> infinite recursion -> stack overflow
To break the cycle, keep the fwnode, but use device_set_of_node_from_dev() for of_node instead. This sets of_node_reused = true, so of_match_device() skips it and the transport driver never matches its own child.
Bonus: refcounting is now balanced too,, device_set_of_node_from_dev() does of_node_get(), which pairs with of_node_put() in platform_device_release()

@amazingfate

Copy link
Copy Markdown
Collaborator

Thank you about this. We are focusing on acpi now so this issue is missed. It's nice to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants